package com.bk.mapper;

import com.bk.entity.Preserve;
import com.bk.vo.LookHistoryVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;

@Mapper
public interface PreserveMapper {
    /**
     * 根据帖子id查看收藏记录
     * @param innoId
     * @return
     */
    @Select("select * from preserve where innovation_id = #{innoId}")
    List<Preserve> getByInnovationId(Long innoId);


    /**
     * 根据userid查询用户浏览记录
     * @param userId
     * @return
     */
    @Select("select i.id innovationId, i.user_id authorName, i.title , i.type,i.image,l.create_time " +
            "from user u,innovation i,look l " +
            "where l.user_id=u.id and  l.innovation_id= i.id and u.id =#{userId}")
    Page<LookHistoryVO> historyPage(Long userId);
}
